use serde::Deserialize;
use serde_with::serde_as;
use std::collections::{HashMap, HashSet};
use std::ops::{Deref, DerefMut};

#[serde_as]
#[derive(Debug, Deserialize, Clone)]
pub struct DistrictTable(#[serde_as(as = "HashMap<_, _>")] pub Vec<(String, HashSet<String>)>);

#[serde_as]
#[derive(Debug, Deserialize, Clone)]
pub struct BatchTable(#[serde_as(as = "HashMap<_, _>")] pub Vec<(u8, DistrictTable)>);

impl Deref for DistrictTable {
    type Target = Vec<(String, HashSet<String>)>;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for DistrictTable {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl Deref for BatchTable {
    type Target = Vec<(u8, DistrictTable)>;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for BatchTable {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
